import axios from "axios";

// 创建实例
const request = axios.create({
  //设置基准地址
  // baseURL: "/api",
  baseURL: import.meta.env.VITE_BASE_URL,
  timeout: 5000,
});

// request 请求拦截器
request.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

// response响应拦截器
request.interceptors.response.use(
  (response) => {
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default request;
